var DebugWindow = GFWindow.extend({
	obj_id: null,
	constructor: function(id)
	{
		var html;
		var x = this;

		this.obj_id = id;
		html = '<span>Debug Console</span><br />';	
		html += '<div nowrap="nowrap" class="main" id="' + id + '_DebugArea"></div><br />';
		html += '<button id="' + id + '_Dec">&lt;</button>';
		html += '<span id="' + id + '_Verbose">&nbsp;</span>';
		html += '<button id="' + id + '_Inc">&gt;</button>';
		html += '&nbsp;<button id="' + id + '_Button">Clear</button>';
		this.base(new GFWindowMovableBehavior(id,400,20,null,null,'DebugWnd'),false,html);

		// get back the button and attach the event
		if(GownFullBrowserDetect.use_addEventListener) {
			var b;

			b = document.getElementById(this.obj_id + '_Button');
			b.addEventListener('click',function() { x.clear(); },false);
			b = document.getElementById(this.obj_id + '_Inc');
			b.addEventListener('click',function() { x.increase_verbose(); },false);
			b = document.getElementById(this.obj_id + '_Dec');
			b.addEventListener('click',function() { x.decrease_verbose(); },false);
		}
		else {
			var b;

			b = document.getElementById(this.obj_id + '_Button');
			b.onclick = function() { x.clear(); }
			b = document.getElementById(this.obj_id + '_Inc');
			b.onclick = function() { x.increase_verbose(); }
			b = document.getElementById(this.obj_id + '_Dec');
			b.onclick = function() { x.decrease_verbose(); }
		}

		this.update_verbose();
	},
	output: function(str)
	{
		var obj,msg;

		obj = document.getElementById(this.obj_id + '_DebugArea');
		if(!obj) return;
		msg = document.createElement('div');
		msg.className = 'msg';
		msg.innerHTML = str;
		obj.insertBefore(msg,obj.firstChild);
//		obj.appendChild(msg);
		obj.scrollTop = 0;
	},
	clear: function()
	{
		var obj;

		obj = document.getElementById(this.obj_id + '_DebugArea');
		if(!obj) return;
		obj.innerHTML = '';
	},
	update_verbose: function()
	{
		var obj;

		obj = document.getElementById(this.obj_id + '_Verbose');
		if(!obj) return;
		if(obj.firstChild) obj.firstChild.nodeValue = 'Verbose: '+Debug.verbose;
	},
	decrease_verbose: function()
	{
		Debug.verbose--;
		Debug.verbose = (Debug.verbose < 0) ? 0 : Debug.verbose;
		this.update_verbose();
	},
	increase_verbose: function()
	{
		Debug.verbose++;
		this.update_verbose();
	}
});
